3.7.98 \(\int \frac {(a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx\) [698]

Optimal. Leaf size=123 \[ \frac {a^3 (A-5 i B) x}{c^2}-\frac {a^3 (i A+5 B) \log (\cos (e+f x))}{c^2 f}+\frac {i a^3 B \tan (e+f x)}{c^2 f}+\frac {2 a^3 (i A+B)}{c^2 f (i+\tan (e+f x))^2}-\frac {4 a^3 (A-2 i B)}{c^2 f (i+\tan (e+f x))} \]

[Out]

a^3*(A-5*I*B)*x/c^2-a^3*(I*A+5*B)*ln(cos(f*x+e))/c^2/f+I*a^3*B*tan(f*x+e)/c^2/f+2*a^3*(I*A+B)/c^2/f/(I+tan(f*x
+e))^2-4*a^3*(A-2*I*B)/c^2/f/(I+tan(f*x+e))

________________________________________________________________________________________

Rubi [A]
time = 0.12, antiderivative size = 123, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, integrand size = 41, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.049, Rules used = {3669, 78} \begin {gather*} -\frac {4 a^3 (A-2 i B)}{c^2 f (\tan (e+f x)+i)}+\frac {2 a^3 (B+i A)}{c^2 f (\tan (e+f x)+i)^2}-\frac {a^3 (5 B+i A) \log (\cos (e+f x))}{c^2 f}+\frac {a^3 x (A-5 i B)}{c^2}+\frac {i a^3 B \tan (e+f x)}{c^2 f} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[((a + I*a*Tan[e + f*x])^3*(A + B*Tan[e + f*x]))/(c - I*c*Tan[e + f*x])^2,x]

[Out]

(a^3*(A - (5*I)*B)*x)/c^2 - (a^3*(I*A + 5*B)*Log[Cos[e + f*x]])/(c^2*f) + (I*a^3*B*Tan[e + f*x])/(c^2*f) + (2*
a^3*(I*A + B))/(c^2*f*(I + Tan[e + f*x])^2) - (4*a^3*(A - (2*I)*B))/(c^2*f*(I + Tan[e + f*x]))

Rule 78

Int[((a_.) + (b_.)*(x_))*((c_) + (d_.)*(x_))^(n_.)*((e_.) + (f_.)*(x_))^(p_.), x_Symbol] :> Int[ExpandIntegran
d[(a + b*x)*(c + d*x)^n*(e + f*x)^p, x], x] /; FreeQ[{a, b, c, d, e, f, n}, x] && NeQ[b*c - a*d, 0] && ((ILtQ[
n, 0] && ILtQ[p, 0]) || EqQ[p, 1] || (IGtQ[p, 0] && ( !IntegerQ[n] || LeQ[9*p + 5*(n + 2), 0] || GeQ[n + p + 1
, 0] || (GeQ[n + p + 2, 0] && RationalQ[a, b, c, d, e, f]))))

Rule 3669

Int[((a_) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((A_.) + (B_.)*tan[(e_.) + (f_.)*(x_)])*((c_) + (d_.)*tan[(e_
.) + (f_.)*(x_)])^(n_.), x_Symbol] :> Dist[a*(c/f), Subst[Int[(a + b*x)^(m - 1)*(c + d*x)^(n - 1)*(A + B*x), x
], x, Tan[e + f*x]], x] /; FreeQ[{a, b, c, d, e, f, A, B, m, n}, x] && EqQ[b*c + a*d, 0] && EqQ[a^2 + b^2, 0]

Rubi steps

\begin {align*} \int \frac {(a+i a \tan (e+f x))^3 (A+B \tan (e+f x))}{(c-i c \tan (e+f x))^2} \, dx &=\frac {(a c) \text {Subst}\left (\int \frac {(a+i a x)^2 (A+B x)}{(c-i c x)^3} \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {(a c) \text {Subst}\left (\int \left (\frac {i a^2 B}{c^3}-\frac {4 i a^2 (A-i B)}{c^3 (i+x)^3}+\frac {4 a^2 (A-2 i B)}{c^3 (i+x)^2}+\frac {a^2 (i A+5 B)}{c^3 (i+x)}\right ) \, dx,x,\tan (e+f x)\right )}{f}\\ &=\frac {a^3 (A-5 i B) x}{c^2}-\frac {a^3 (i A+5 B) \log (\cos (e+f x))}{c^2 f}+\frac {i a^3 B \tan (e+f x)}{c^2 f}+\frac {2 a^3 (i A+B)}{c^2 f (i+\tan (e+f x))^2}-\frac {4 a^3 (A-2 i B)}{c^2 f (i+\tan (e+f x))}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B] Both result and optimal contain complex but leaf count is larger than twice the leaf count of optimal. \(285\) vs. \(2(123)=246\).
time = 5.34, size = 285, normalized size = 2.32 \begin {gather*} \frac {a^3 \left (2 (i A+3 B) \cos (2 f x) \cos (e+f x) (\cos (e)-i \sin (e))+(A-i B) \cos (4 f x) \cos (e+f x) (-i \cos (e)+\sin (e))+2 (A-5 i B) f x \cos (e+f x) (\cos (3 e)-i \sin (3 e))-i (A-5 i B) \cos (e+f x) \log \left (\cos ^2(e+f x)\right ) (\cos (3 e)-i \sin (3 e))+2 B \sec (e) (i \cos (3 e)+\sin (3 e)) \sin (f x)+(A-3 i B) \cos (e+f x) (-2 \cos (e)+2 i \sin (e)) \sin (2 f x)+(A-i B) \cos (e+f x) (\cos (e)+i \sin (e)) \sin (4 f x)\right ) (\cos (e+f x)+i \sin (e+f x))^3 (A+B \tan (e+f x))}{2 c^2 f (\cos (f x)+i \sin (f x))^3 (A \cos (e+f x)+B \sin (e+f x))} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[((a + I*a*Tan[e + f*x])^3*(A + B*Tan[e + f*x]))/(c - I*c*Tan[e + f*x])^2,x]

[Out]

(a^3*(2*(I*A + 3*B)*Cos[2*f*x]*Cos[e + f*x]*(Cos[e] - I*Sin[e]) + (A - I*B)*Cos[4*f*x]*Cos[e + f*x]*((-I)*Cos[
e] + Sin[e]) + 2*(A - (5*I)*B)*f*x*Cos[e + f*x]*(Cos[3*e] - I*Sin[3*e]) - I*(A - (5*I)*B)*Cos[e + f*x]*Log[Cos
[e + f*x]^2]*(Cos[3*e] - I*Sin[3*e]) + 2*B*Sec[e]*(I*Cos[3*e] + Sin[3*e])*Sin[f*x] + (A - (3*I)*B)*Cos[e + f*x
]*(-2*Cos[e] + (2*I)*Sin[e])*Sin[2*f*x] + (A - I*B)*Cos[e + f*x]*(Cos[e] + I*Sin[e])*Sin[4*f*x])*(Cos[e + f*x]
 + I*Sin[e + f*x])^3*(A + B*Tan[e + f*x]))/(2*c^2*f*(Cos[f*x] + I*Sin[f*x])^3*(A*Cos[e + f*x] + B*Sin[e + f*x]
))

________________________________________________________________________________________

Maple [A]
time = 0.30, size = 83, normalized size = 0.67

method result size
derivativedivides \(\frac {a^{3} \left (i B \tan \left (f x +e \right )-\frac {-8 i B +4 A}{i+\tan \left (f x +e \right )}+\left (i A +5 B \right ) \ln \left (i+\tan \left (f x +e \right )\right )-\frac {-4 i A -4 B}{2 \left (i+\tan \left (f x +e \right )\right )^{2}}\right )}{f \,c^{2}}\) \(83\)
default \(\frac {a^{3} \left (i B \tan \left (f x +e \right )-\frac {-8 i B +4 A}{i+\tan \left (f x +e \right )}+\left (i A +5 B \right ) \ln \left (i+\tan \left (f x +e \right )\right )-\frac {-4 i A -4 B}{2 \left (i+\tan \left (f x +e \right )\right )^{2}}\right )}{f \,c^{2}}\) \(83\)
risch \(-\frac {{\mathrm e}^{4 i \left (f x +e \right )} B \,a^{3}}{2 c^{2} f}-\frac {i {\mathrm e}^{4 i \left (f x +e \right )} A \,a^{3}}{2 c^{2} f}+\frac {3 \,{\mathrm e}^{2 i \left (f x +e \right )} B \,a^{3}}{c^{2} f}+\frac {i {\mathrm e}^{2 i \left (f x +e \right )} A \,a^{3}}{c^{2} f}+\frac {10 i a^{3} B e}{c^{2} f}-\frac {2 a^{3} A e}{c^{2} f}-\frac {2 B \,a^{3}}{f \,c^{2} \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}-\frac {5 a^{3} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) B}{c^{2} f}-\frac {i a^{3} \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right ) A}{c^{2} f}\) \(189\)
norman \(\frac {\frac {\left (-5 i B \,a^{3}+A \,a^{3}\right ) x}{c}+\frac {2 i A \,a^{3}+6 B \,a^{3}}{c f}+\frac {\left (-5 i B \,a^{3}+A \,a^{3}\right ) x \left (\tan ^{4}\left (f x +e \right )\right )}{c}+\frac {i B \,a^{3} \left (\tan ^{5}\left (f x +e \right )\right )}{c f}+\frac {2 \left (-5 i B \,a^{3}+A \,a^{3}\right ) x \left (\tan ^{2}\left (f x +e \right )\right )}{c}-\frac {2 \left (-5 i B \,a^{3}+2 A \,a^{3}\right ) \left (\tan ^{3}\left (f x +e \right )\right )}{c f}+\frac {2 \left (3 i A \,a^{3}+5 B \,a^{3}\right ) \left (\tan ^{2}\left (f x +e \right )\right )}{c f}+\frac {5 i B \,a^{3} \tan \left (f x +e \right )}{c f}}{c \left (1+\tan ^{2}\left (f x +e \right )\right )^{2}}+\frac {\left (i A \,a^{3}+5 B \,a^{3}\right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2 c^{2} f}\) \(244\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+I*a*tan(f*x+e))^3*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x,method=_RETURNVERBOSE)

[Out]

1/f*a^3/c^2*(I*B*tan(f*x+e)-(-8*I*B+4*A)/(I+tan(f*x+e))+(I*A+5*B)*ln(I+tan(f*x+e))-1/2*(-4*I*A-4*B)/(I+tan(f*x
+e))^2)

________________________________________________________________________________________

Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: RuntimeError} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))^3*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x, algorithm="maxima")

[Out]

Exception raised: RuntimeError >> ECL says: Error executing code in Maxima: expt: undefined: 0 to a negative e
xponent.

________________________________________________________________________________________

Fricas [A]
time = 4.18, size = 144, normalized size = 1.17 \begin {gather*} \frac {{\left (-i \, A - B\right )} a^{3} e^{\left (6 i \, f x + 6 i \, e\right )} + {\left (i \, A + 5 \, B\right )} a^{3} e^{\left (4 i \, f x + 4 i \, e\right )} - 2 \, {\left (-i \, A - 3 \, B\right )} a^{3} e^{\left (2 i \, f x + 2 i \, e\right )} - 4 \, B a^{3} - 2 \, {\left ({\left (i \, A + 5 \, B\right )} a^{3} e^{\left (2 i \, f x + 2 i \, e\right )} + {\left (i \, A + 5 \, B\right )} a^{3}\right )} \log \left (e^{\left (2 i \, f x + 2 i \, e\right )} + 1\right )}{2 \, {\left (c^{2} f e^{\left (2 i \, f x + 2 i \, e\right )} + c^{2} f\right )}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))^3*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x, algorithm="fricas")

[Out]

1/2*((-I*A - B)*a^3*e^(6*I*f*x + 6*I*e) + (I*A + 5*B)*a^3*e^(4*I*f*x + 4*I*e) - 2*(-I*A - 3*B)*a^3*e^(2*I*f*x
+ 2*I*e) - 4*B*a^3 - 2*((I*A + 5*B)*a^3*e^(2*I*f*x + 2*I*e) + (I*A + 5*B)*a^3)*log(e^(2*I*f*x + 2*I*e) + 1))/(
c^2*f*e^(2*I*f*x + 2*I*e) + c^2*f)

________________________________________________________________________________________

Sympy [A]
time = 0.54, size = 236, normalized size = 1.92 \begin {gather*} - \frac {2 B a^{3}}{c^{2} f e^{2 i e} e^{2 i f x} + c^{2} f} - \frac {i a^{3} \left (A - 5 i B\right ) \log {\left (e^{2 i f x} + e^{- 2 i e} \right )}}{c^{2} f} + \begin {cases} \frac {\left (2 i A a^{3} c^{2} f e^{2 i e} + 6 B a^{3} c^{2} f e^{2 i e}\right ) e^{2 i f x} + \left (- i A a^{3} c^{2} f e^{4 i e} - B a^{3} c^{2} f e^{4 i e}\right ) e^{4 i f x}}{2 c^{4} f^{2}} & \text {for}\: c^{4} f^{2} \neq 0 \\\frac {x \left (2 A a^{3} e^{4 i e} - 2 A a^{3} e^{2 i e} - 2 i B a^{3} e^{4 i e} + 6 i B a^{3} e^{2 i e}\right )}{c^{2}} & \text {otherwise} \end {cases} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))**3*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))**2,x)

[Out]

-2*B*a**3/(c**2*f*exp(2*I*e)*exp(2*I*f*x) + c**2*f) - I*a**3*(A - 5*I*B)*log(exp(2*I*f*x) + exp(-2*I*e))/(c**2
*f) + Piecewise((((2*I*A*a**3*c**2*f*exp(2*I*e) + 6*B*a**3*c**2*f*exp(2*I*e))*exp(2*I*f*x) + (-I*A*a**3*c**2*f
*exp(4*I*e) - B*a**3*c**2*f*exp(4*I*e))*exp(4*I*f*x))/(2*c**4*f**2), Ne(c**4*f**2, 0)), (x*(2*A*a**3*exp(4*I*e
) - 2*A*a**3*exp(2*I*e) - 2*I*B*a**3*exp(4*I*e) + 6*I*B*a**3*exp(2*I*e))/c**2, True))

________________________________________________________________________________________

Giac [B] Both result and optimal contain complex but leaf count of result is larger than twice the leaf count of optimal. 357 vs. \(2 (113) = 226\).
time = 0.82, size = 357, normalized size = 2.90 \begin {gather*} \frac {\frac {6 \, {\left (-i \, A a^{3} - 5 \, B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 1\right )}{c^{2}} + \frac {12 \, {\left (i \, A a^{3} + 5 \, B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i\right )}{c^{2}} - \frac {6 \, {\left (i \, A a^{3} + 5 \, B a^{3}\right )} \log \left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 1\right )}{c^{2}} - \frac {6 \, {\left (-i \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 5 \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} + 2 i \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i \, A a^{3} + 5 \, B a^{3}\right )}}{{\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 1\right )} c^{2}} - \frac {25 i \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} + 125 \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{4} - 100 \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} + 548 i \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{3} - 198 i \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - 894 \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} + 100 \, A a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 548 i \, B a^{3} \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 25 i \, A a^{3} + 125 \, B a^{3}}{c^{2} {\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + i\right )}^{4}}}{6 \, f} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+I*a*tan(f*x+e))^3*(A+B*tan(f*x+e))/(c-I*c*tan(f*x+e))^2,x, algorithm="giac")

[Out]

1/6*(6*(-I*A*a^3 - 5*B*a^3)*log(tan(1/2*f*x + 1/2*e) + 1)/c^2 + 12*(I*A*a^3 + 5*B*a^3)*log(tan(1/2*f*x + 1/2*e
) + I)/c^2 - 6*(I*A*a^3 + 5*B*a^3)*log(tan(1/2*f*x + 1/2*e) - 1)/c^2 - 6*(-I*A*a^3*tan(1/2*f*x + 1/2*e)^2 - 5*
B*a^3*tan(1/2*f*x + 1/2*e)^2 + 2*I*B*a^3*tan(1/2*f*x + 1/2*e) + I*A*a^3 + 5*B*a^3)/((tan(1/2*f*x + 1/2*e)^2 -
1)*c^2) - (25*I*A*a^3*tan(1/2*f*x + 1/2*e)^4 + 125*B*a^3*tan(1/2*f*x + 1/2*e)^4 - 100*A*a^3*tan(1/2*f*x + 1/2*
e)^3 + 548*I*B*a^3*tan(1/2*f*x + 1/2*e)^3 - 198*I*A*a^3*tan(1/2*f*x + 1/2*e)^2 - 894*B*a^3*tan(1/2*f*x + 1/2*e
)^2 + 100*A*a^3*tan(1/2*f*x + 1/2*e) - 548*I*B*a^3*tan(1/2*f*x + 1/2*e) + 25*I*A*a^3 + 125*B*a^3)/(c^2*(tan(1/
2*f*x + 1/2*e) + I)^4))/f

________________________________________________________________________________________

Mupad [B]
time = 9.16, size = 182, normalized size = 1.48 \begin {gather*} -\frac {a^3\,\left (7\,B\,\mathrm {tan}\left (e+f\,x\right )+B\,6{}\mathrm {i}+A\,\mathrm {tan}\left (e+f\,x\right )\,4{}\mathrm {i}-2\,A+B\,{\mathrm {tan}\left (e+f\,x\right )}^2\,2{}\mathrm {i}+B\,{\mathrm {tan}\left (e+f\,x\right )}^3-A\,\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )+B\,\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,5{}\mathrm {i}+A\,\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\mathrm {tan}\left (e+f\,x\right )\,2{}\mathrm {i}+10\,B\,\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\mathrm {tan}\left (e+f\,x\right )+A\,\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,{\mathrm {tan}\left (e+f\,x\right )}^2-B\,\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,{\mathrm {tan}\left (e+f\,x\right )}^2\,5{}\mathrm {i}\right )\,1{}\mathrm {i}}{c^2\,f\,{\left (-1+\mathrm {tan}\left (e+f\,x\right )\,1{}\mathrm {i}\right )}^2} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(((A + B*tan(e + f*x))*(a + a*tan(e + f*x)*1i)^3)/(c - c*tan(e + f*x)*1i)^2,x)

[Out]

-(a^3*(B*6i - 2*A + A*tan(e + f*x)*4i + 7*B*tan(e + f*x) + B*tan(e + f*x)^2*2i + B*tan(e + f*x)^3 - A*log(tan(
e + f*x) + 1i) + B*log(tan(e + f*x) + 1i)*5i + A*log(tan(e + f*x) + 1i)*tan(e + f*x)*2i + 10*B*log(tan(e + f*x
) + 1i)*tan(e + f*x) + A*log(tan(e + f*x) + 1i)*tan(e + f*x)^2 - B*log(tan(e + f*x) + 1i)*tan(e + f*x)^2*5i)*1
i)/(c^2*f*(tan(e + f*x)*1i - 1)^2)

________________________________________________________________________________________